package MouseInheritage;

abstract class Mouse {
    private String color; // contains mouse color
    private int posX = 0, posY = 0; // contains current mouse position
    private int maxX = 0, maxY = 0; // contain the size of the screen: maxX - vertical; maxY - horizontal.

    //This method return mouse color
    public String GetColor() {
        return color;
    }

    //This method set mouse color
    public void SetColor(String color) {
        this.color = color;
    }


    //This method return mouse position on axis X
    public int GetPosX() {
        return posX;
    }

    //This method set mouse position on axis X
    private void SetPosX(int posX){

        if (posX >= 0 && posX <= maxX ) {
            this.posX = posX;
        } else {
            this.posX = posX < 0 ? 0 : maxX;
        }

    }

    //This method return mouse position on axis Y
    public int GetPosY() {
        return posY;
    }

    //This method set mouse position on axis Y
    private void SetPosY(int posY){

        if (posY >= 0 && posY <= maxY) {
            this.posY = posY;
        } else {
            this.posY = posY < 0 ? 0 : maxY;
        }

    }

    //This method return size of the screen on axis X
    public int GetMaxX() {
        return maxX;
    }

    //This method set size of the screen on axis X
    private void SetMaxX(int maxX) {
        if (maxX > 0) {
            this.maxX = maxX;
        } else {
            System.out.println("Attention! Screen size must be greater than zero.");
            this.maxX = 0;
        }

    }

    //This method return size of the screen on axis Y
    public int GetMaxY() {
        return maxY;
    }

    //This method set size of the screen on axis Y
    private void SetMaxY(int maxY) {
        if (maxY > 0) {
            this.maxY = maxY;
        } else {
            System.out.println("Attention! Screen size must be greater than zero.");
            this.maxY = 0;
        }

    }

    //This method handles the event click on the left mouse button
    abstract void LeftButtonClick();

    //This method handles the event click on the right mouse button
    abstract void RightButtonClick();

    //This method defines size of the screen
    public void SetScreenResolution(int maxX, int maxY){
        SetMaxX(maxX);
        SetMaxY(maxY);
    }

    //This method set mouse position on axis X and Y
    public void SetMousePosition(int posX, int posY) {
        SetPosX(posX);
        SetPosY(posY);
    }

    //This method informs user about coordinates of the mouse cursor
    public String GetMousePosition(){
        return ("Mouse position: X - " + GetPosX() + ": Y - " + GetPosY());
    }

    //This method informs user about screen resolution
    public String GetScreenResolution(){
        return ("Screen resolution: " + GetMaxX() + " * " + GetMaxY());
    }

    //This method realised mouse move
    public void Move(int stepX, int stepY) {

        SetMousePosition(posX + stepX, posY + stepY);

        //this bloc describes reaction on mouse movement
        if (stepX < 0) {
            if (stepY < 0){
                System.out.println("Downward movement to the left");
            }else if (stepY == 0) {
                System.out.println("Downward movement");
            }else {
                System.out.println("Downward movement to the right");
            }
        }else if (stepX == 0){
            if (stepY < 0){
                System.out.println("Move left");
            }else if (stepY == 0) {
                System.out.println("Mouse remain in place");
            }else {
                System.out.println("Move right");
            }
        }else {
            if (stepY < 0){
                System.out.println("Upward movement to the left");
            }else if (stepY == 0) {
                System.out.println("Upward movement");
            }else {
                System.out.println("Upward movement to the right");
            }

        }

        int currentPosX = GetPosX();
        int currentPosY = GetPosY();

        //this bloc describes reaction on result of mouse movement
        if (currentPosX == maxX && currentPosY == maxY) {
            System.out.println("Reached the top right corner");
        }else if(currentPosX == 0 && currentPosY == maxY){
            System.out.println("Reached the bottom right corner");
        }else if(currentPosX == 0 && currentPosY == 0){
            System.out.println("Reached the bottom left corner");
        }else if(currentPosX == maxX && currentPosY == 0){
            System.out.println("Reached the top left corner");
        }else if(currentPosX == 0){
            System.out.println("Reached the bottom edge");
        }else if(currentPosX == maxX){
            System.out.println("Reached the top edge");
        }else if(currentPosY == maxY){
            System.out.println("Reached the right edge");
        }else if(currentPosY == 0) {
            System.out.println("Reached the left edge");
        }
    }

}
